< previous page page_739 next page >

Page 739
0739-01.jpg
Figure 19.9.
Adding the frmSQLData utility form to the project.
Next, you need to code the ExecDirect method. This is the wrapper method for the SQLDirectExec API call. Add the code in Listing 19.12 to the class module.
Type.gifListing 19.12. Coding the ExecDirect method.
Public Function ExecDirect()
    '
    ' perform an SQL statement
    '
    Dim intResult As Integer
    '
    ' clear any in-process stuff
    If hStmt <> 0 Then
        intResult = SQLFreeStmt(hStmt, sqlClose)
        intResult = SQLFreeStmt(hStmt, sqlUnbind)
        intResult = SQLFreeStmt(hStmt, sqlResetParams)
    End If
    '
    If intResult <> sqlSuccess Then
        ExecDirect = intResult
        Err.Raise vbObjectError + 11, App.EXEName, "Error freeing old statement
handle"
        intResult = SQLFreeStmt(hStmt, sqlClose)
        Exit Function
    End If
    '
    ' Do the query & wait
    intResult = SQLExecDirect(hStmt, SQL, Len(SQL))
    Do While intResult = sqlStillExecuting
        intResult = SQLExecDirect(hStmt, SQL, Len(SQL))
        DoEvents
    Loop
    '
    ' check for errors
    If intResult <> sqlSuccess Then
continues

 
< previous page page_739 next page >

If you like this book, buy it!